import uuid

from langgraph.store.memory import InMemoryStore

inmemory_store = InMemoryStore()
user_id = "example_user"
namespace_for_user_data = (user_id, "user_info",'jack')

memory_key = uuid.uuid4().hex

memory_value = {"user_name":"ExampleUser",
                "user_id":user_id, "namespace_for_user_data":namespace_for_user_data}
#使用put将记忆存储在memory store
inmemory_store.put(namespace_for_user_data,memory_key, memory_value)
# print(f'已保存{memory_key}')

inmemory_store.put(namespace_for_user_data,memory_key, {"user_name":"周宇",
                "user_id":user_id})
#检索
all_user_memories = inmemory_store.search(namespace_for_user_data)
for record in all_user_memories:
    # print(record.dict())
    print('ss')

# 通过key检索
memory_kv = inmemory_store.get(namespace_for_user_data,memory_key)
print(memory_kv)